package com.example.consumer.listen;

import java.time.LocalDateTime;

import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import com.example.common.model.CommonConstant;

@Component
@RocketMQMessageListener(consumerGroup = CommonConstant.MQ_TOPIC + "_CONSUMER", topic = CommonConstant.MQ_TOPIC, messageModel = MessageModel.CLUSTERING)
public class HelloMqListener1 implements RocketMQListener<String> {

    @Override
    public void onMessage(String s) {
        //        try {
        //            TimeUnit.SECONDS.sleep(2);
        //        } catch (InterruptedException e) {
        //            throw new RuntimeException(e);
        //        }
        System.out.println("1 接收到消息: " + s + ", 当前时间: " + LocalDateTime.now());
    }

}
